package training.bms.presentation;

import javax.faces.bean.ManagedBean;

import training.bms.business.Blog;
import training.bms.business.BlogController;
import training.bms.business.BlogPanel;
import training.bms.business.BlogSearchOptions;
import training.framework.business.AbstractEntityController;
import training.framework.presentation.AbstractNewEntity;

@ManagedBean
public class NewBlog extends AbstractNewEntity<Integer, Blog, BlogSearchOptions, BlogPanel>{

	private BlogController controller;

	public NewBlog() {
		super(
				Blog.class, 
				BlogPanel.class, 
				"newBlog", 
				"Blog has been successfully saved!"
				);
		controller = new BlogController();
	}

	@Override
	protected AbstractEntityController<Integer, Blog, BlogSearchOptions> getController() {
		return controller;
	}

	/*private Blog blog;
	private boolean blogSaved;
	
	public NewBlog() {
		initialize();
	}
	
	public String initialize() {
		blog = new Blog();
		blogSaved = false;
		return "newBlog";
	}

	public void setBlog(Blog blog) {
		this.blog = blog;
	}
	
	public Blog getBlog() {
		return blog;
	}
	
	public void setBlogSaved(boolean blogSaved) {
		this.blogSaved = blogSaved;
	}

	public boolean getBlogSaved() {
		return blogSaved;
	}	
	
	public void saveBlog() {
		FacesMessage message = new FacesMessage();
		
		BlogController controller = new BlogController();
		controller.saveEntity(blog);
		blogSaved = true;
		message.setSummary("Blog has been successfully saved");
		message.setSeverity(FacesMessage.SEVERITY_INFO);
		FacesContext context = FacesContext.getCurrentInstance();
		context.addMessage(null, message);					
	}*/
}